package com.sz.app.supplier.web.swagger;

import com.sz.biz.app.utils.SwaggerUtils;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * Function: Swagger2 <br>
 * Author: Charles <br>
 * Date: 2016-11-02 13:11:00
 */
@Configuration
@EnableSwagger2
public class Swagger2 {

    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(SwaggerUtils.basePackages(new String[]{"com.sz.biz.app.web.api",
                        "com.sz.app.supplier.web.api"}))
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("Logistics platform RESTful APIs")
                .description("Logistics platform RESTful APIs document")
                .termsOfServiceUrl("http://xxxx.com/")
                .contact(new Contact("Charles", "http://www.logistics.biz", "qianb.li@hnair.com"))
                .version("1.0")
                .build();
    }

}